<h3>Asks for feedbacks</h3>
<?php

require_once("classes/db.class.php");
require_once("classes/work.class.php");
require_once("classes/user.class.php");
require_once("classes/category.class.php");

$uid = $_SESSION['uid'];
//$uid = 3;

//SELECT `asks`.`workid` FROM `asks` INNER JOIN `works` ON `asks`.`workid` = `works`.`id` WHERE `asks`.`foruid` = '3' ORDER BY `works`.`date` ASC

if (isset($_GET['s'])) {
    if ($_GET['s']=="d")
        $uzkl = "SELECT `asks`.`workid` FROM `asks` INNER JOIN `works` ON `asks`.`workid` = `works`.`id` WHERE `asks`.`foruid` = '" . $_SESSION['uid'] . "' ORDER BY `works`.`date` DESC";
    else
        $uzkl = "SELECT `asks`.`workid` FROM `asks` INNER JOIN `works` ON `asks`.`workid` = `works`.`id` WHERE `asks`.`foruid` = '" . $_SESSION['uid'] . "' ORDER BY `works`.`date` ASC";
} else 
    $uzkl = "SELECT `asks`.`workid` FROM `asks` INNER JOIN `works` ON `asks`.`workid` = `works`.`id` WHERE `asks`.`foruid` = '" . $_SESSION['uid'] . "'";
$a = $db->query($uzkl);


echo "<ul>";
while ($data = $db->fetch($a)) {
    printData($data->workid);
}
echo "</ul>";


function printData($workid) {
    $work = new Work($workid);
    if ($work->isTimeout() == 0) {
        echo "<li>";
        $usr = new User($work->getUserId());
        echo $usr->getName() . " " . $usr->getSurname() . " did " . $work->getDescription() . " on ";
        $cat = new Category($work->getCategoryId());
        echo $cat->getName() . " " . $work->getDate() . ". KNOPKE:GIVEFEEDBACK</li>";
    }
    
}
?>
